package com.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/session1")
public class MySession extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //Session是服务端的一个会话技术
        //数据保存在服务端
        HttpSession session = req.getSession();
        resp.getWriter().write(session.toString());
        session.setAttribute("s1","zzz");
        //Session什么时候被销毁 cookie失效过半小时会被服务器自动销毁
        //手动销毁 自动销毁(超时)


    }
}
